import 'package:bxultimate/app/router/router_name.dart';
import 'package:bxultimate/app/theme/app_theme.dart';
import 'package:bxultimate/app/theme/gaps.dart';
import 'package:bxultimate/data/store/auth_store.dart';
import 'package:bxultimate/shared/util/util_mk.dart';
import 'package:bxultimate/widgets/mk_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

import 'controller.dart';

class UserPrivacyInfoCollectPage extends StatefulWidget {
  const UserPrivacyInfoCollectPage({Key? key}) : super(key: key);

  @override
  State<UserPrivacyInfoCollectPage> createState() =>
      _UserPrivacyInfoCollectPageState();
}

class _UserPrivacyInfoCollectPageState
    extends State<UserPrivacyInfoCollectPage> {
  final controller = Get.find<UserPrivacyInfoCollectController>();
  final state = Get.find<UserPrivacyInfoCollectController>().state;

  @override
  Widget build(BuildContext context) {
    return MkPage(
        child: Scaffold(
      backgroundColor: Colors.transparent,
      appBar: TDNavBar(
        backgroundColor: Colors.transparent,
        title: '个人信息收集清单',
      ),
      body: SingleChildScrollView(
        padding: const EdgeInsets.all(AppTheme.iDefaultPadding),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Center(
              child: Container(
                padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20),
                decoration: BoxDecoration(
                  color: Colors.white,
                ),
                child: Text(
                  '兵馨将尽全力保护你的个人信息安全，并保障你的个人信息处理中的权益。你可以按照时间周期查询对你个人信息的收集、处理情况，并对个人信息进行便捷的管理。',
                ),
              ),
            ),
            Gaps.vGap12,
            Text('信息收集'),
            Gaps.vGap12,
            TDCell(
              title: '个人资料',
              arrow: true,
              onClick: (TDCell d) {
                UtilMk.openBottomSheet(500, '个人资料', Container(
                  height: 400,
                  child:_buildInfo(),
                ));
              },
            ),
            TDCell(
              title: '使用过程中',
              arrow: true,
              onClick: (TDCell d) {
                UtilMk.openBottomSheet(500, '使用过程中', Container(
                  height: 400,
                  child:SingleChildScrollView(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Padding(padding:EdgeInsets.symmetric(vertical: 20,horizontal: 20),child: Text('位置信息')),
                        TDCell(title: '信息内容',note: '${AuthStore.to.profile.mobile}',),
                        TDCell(title: '信息目的',note: '用于向你推荐你可能感兴趣的内容'),
                        TDCell(title: '使用场景',note: '您首次注册时'),
                        TDCell(title: '收集情况',note: '收集1次'),
                      ],
                    ),
                  ),
                ));
              },
            ),


            Gaps.vGap12,
            Text('查看其他信息'),
            Gaps.vGap12,
            TDCell(
              title: '账号资料',
              arrow: true,
                onClick: (TDCell d) {
                  UtilMk.openBottomSheet(500, '账号资料', Container(
                    height: 400,
                    child:SingleChildScrollView(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Padding(padding:EdgeInsets.symmetric(vertical: 20,horizontal: 20),child: Text('账号资料')),
                          TDCell(title: '信息内容',noteWidget: GestureDetector(onTap: (){
                            Get.toNamed(RouterName.userInformationComplete);
                          },child: Text('完善资料',style: TextStyle(color: Colors.blueAccent)),),),
                          TDCell(title: '信息目的',note: '您完善的基本资料'),
                          TDCell(title: '使用场景',note: '资料完善'),
                          TDCell(title: '收集情况',note: '收集1次'),
                        ],
                      ),
                    ),
                  ));
                }
            ),
          ],
        ),
      ),
    ));
  }

  _buildInfo(){
    return SingleChildScrollView(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Padding(padding:EdgeInsets.symmetric(vertical: 20,horizontal: 20),child: Text('手机号')),
          TDCell(title: '信息内容',note: '${AuthStore.to.profile.mobile}',),
          TDCell(title: '信息目的',note: '为您创建账号'),
          TDCell(title: '使用场景',note: '您首次注册时'),
          TDCell(title: '收集情况',note: '收集1次'),
          Padding(padding:EdgeInsets.symmetric(vertical: 20,horizontal: 20),child: Text('基本资料')),
          TDCell(title: '信息内容',noteWidget: GestureDetector(onTap: (){
            Get.toNamed(RouterName.userInformation);
          },child: Text('基本资料',style: TextStyle(color: Colors.blueAccent)),),),
          TDCell(title: '信息目的',note: '为您创建账号'),
          TDCell(title: '使用场景',note: '您首次注册时'),
          TDCell(title: '收集情况',note: '收集1次')
        ],
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<UserPrivacyInfoCollectController>();
    super.dispose();
  }
}
